import React from 'react'
import { HashRouter, Redirect, Route, Switch } from 'react-router-dom/cjs/react-router-dom.min'
import Login from '../views/login/Login'
import NewsSendBox from '../views/sandbox/NewsSendBox'
import Detail from '../views/visit/Detail'
import Visitor from '../views/visit/Visitor'

export default function IndexRouter() {
  return (
    <HashRouter>
      <Switch>
        <Route path='/visitor' component={Visitor}></Route>
        <Route path='/detail/:id' component={Detail}></Route>
        <Route path='/login' component={Login}></Route>
        <Route path='/' render={() => localStorage.getItem('token') ? <NewsSendBox></NewsSendBox> : <Redirect to='/login'></Redirect>}></Route>
      </Switch>
    </HashRouter>
  )
}
